//
//  NSECGRealTimeView.h
//  SpeedTest
//
//  Created by Han Mingjie on 2020/2/10.
//  Copyright © 2020 MingJie Han. All rights reserved.
//

#import <TargetConditionals.h>
//#import "NSECGRealTimeOSControl.h"

#ifndef NSECGRealTimeOSControl_h
#define NSECGRealTimeOSControl_h

#if TARGET_OS_IOS
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif

#if TARGET_OS_OSX
#define UIColor NSColor
#define UIFont NSFont
#define CGRect NSRect
#define UIView NSView
#endif

#endif /* NSECGRealTimeOSControl_h */

typedef NS_ENUM(NSInteger, NSECGRealTimeView_Style) {
    NSECGRealTimeView_Style_12x1 = 1,
    NSECGRealTimeView_Style_6x2 = 2,
    NSECGRealTimeView_Style_3x4 = 3,
    NSECGCustom_Style = 4,
    NSECGRealTimeView_Style_limb_leads = 5      //6x1
};


// NSECGRealTimeView_Standard_Auto
// Standard Show at NSECGRealTimeView_Style_6x2 NSECGRealTimeView_Style_limb_leads
// 如果定标重合，则只显示偶数行的定标 at NSECGRealTimeView_Style_12x1
// 只显示长导联的定标， 其他定标不显示 at NSECGRealTimeView_Style_3x4
typedef NS_ENUM(NSInteger, NSECGRealTimeView_Standard) {
    NSECGRealTimeView_Standard_Show = 1,
    NSECGRealTimeView_Standard_Hidden = 2,
    NSECGRealTimeView_Standard_Auto = 0     //Default
};

NS_ASSUME_NONNULL_BEGIN
@protocol NSECGRealTimeViewDelegate;

@interface UIECGRecordingView:UIView{
    id <NSECGRealTimeViewDelegate> _Nullable delegate;
    NSArray <NSString *>*ecg_name_array;            //ECG lead name @[@"I", ...]
    NSArray <NSNumber *>*ecg_lead_status;           //ECG lead status
    NSECGRealTimeView_Style style;      //default style is NSECGRealTimeView_Style_3x4
    NSString *long_lead_name;           //3x4 or 6x2 Only
    NSECGRealTimeView_Standard standard_style;       //Default is NSECGRealTimeView_Standard_Auto
    float x_speed;                      //纸速 默认 25.f 50.f 12.5f mm/s
    float y_rate;                       //振幅 默认 10.f 20.f 5.f  mm/mV
    float view_fresh;                   //ECG refreah Hz default 25.f
    float ECG_rate;                     //How many point per second from BLE about ECG default 660.f
    float pix_per_mm;                   //每个毫米是多少像素点 default 5.f
    NSUInteger space_pix;               //头尾距离像素数量，默认 30
    float ecg_line_width;                   //ECG line Color default is 1.6
    UIColor *ecg_line_color;                //ECG line Color default is green
    UIColor *standard_text_color;
    UIFont *standard_text_font;
    UIColor *lost_line_color;               //ECG color when lead have lost.
    float bg5mmWidth;            //strong line width for background, default is 0.8
    UIColor *bg5mmColor;         //background strong line color, default is darkGrayColor
    
    float bg1mmWidth;      //weak line width for background, default is 0.2
    float bg10mmWidth;

    UIColor *bg10mmColor;   //
    UIColor *bg1mmColor;    //background weak line color, default is darkGrayColor
    UIColor *background_color;              //ECG's background color, default is black
    
}
@property (nonatomic) id <NSECGRealTimeViewDelegate> _Nullable delegate;
@property (nonatomic) NSArray *ecg_name_array;
@property (nonatomic) NSArray <NSNumber *>*ecg_lead_status;
@property (nonatomic) NSECGRealTimeView_Style style;
@property (nonatomic) NSString *long_lead_name;
@property (nonatomic) NSECGRealTimeView_Standard standard_style;
@property (nonatomic) float x_speed;
@property (nonatomic) float y_rate;
@property (nonatomic) float view_fresh;
@property (nonatomic) float ECG_rate;
@property (nonatomic) float pix_per_mm;
@property (nonatomic) NSUInteger space_pix;     //distance from drawing header to line,default is 2 mm;
@property (nonatomic) float space3x4PerRow;     //default is 0.f mm;
@property (nonatomic) float space6x2PerRow;     //default is 0.f mm;
@property (nonatomic) float ecg_line_width;
@property (nonatomic) UIColor *ecg_line_color;
@property (nonatomic) UIColor *standard_text_color;
@property (nonatomic) UIFont *standard_text_font;
@property (nonatomic) UIColor *lost_line_color;
@property (nonatomic) float bg10mmWidth;
@property (nonatomic) float bg5mmWidth;
@property (nonatomic) float bg1mmWidth;
@property (nonatomic) UIColor *bg10mmColor;
@property (nonatomic) UIColor *bg5mmColor;
@property (nonatomic) UIColor *bg1mmColor;

@property (nonatomic) UIColor *background_color;

-(BOOL)add_realtime_ECG_in_thread:(NSArray <NSArray <NSNumber *>*>* )ecg_array;

//clean ECG in control cache.
-(BOOL)cleanControlCache;
@end

@protocol NSECGRealTimeViewDelegate <NSObject>
@optional
-(void)clickedLead:(NSString *)lead_name;
@end

NS_ASSUME_NONNULL_END
